function setError() {
  $('#status').html(GT2ICROCX.ErrMsg);
}

function setResult(succ) {
  if (succ) {
    $('#status').removeClass('warn').addClass('succ');
    $('#IdCard').find('input').each(function() {
      $(this).val(GT2ICROCX[$(this).attr('id')]);
    });
    $('#photo').val(GT2ICROCX.GetPhotoBuffer());
    $('#faceJpg1').val(GT2ICROCX.GetFaceJpgBase64(1));
    $('#faceJpg2').val(GT2ICROCX.GetFaceJpgBase64(2));
    $('#faceJpg0').val(GT2ICROCX.GetFaceJpgBase64(0));
    $('#photoimg').attr('src', 'data:image/jpg;base64,' + GT2ICROCX.GetPhotoBuffer());
    $('#faceJpg1img').attr('src', 'data:image/jpg;base64,' + GT2ICROCX.GetFaceJpgBase64(1));
    $('#faceJpg2img').attr('src', 'data:image/jpg;base64,' + GT2ICROCX.GetFaceJpgBase64(2));
    $('#faceJpg0img').attr('src', 'data:image/jpg;base64,' + GT2ICROCX.GetFaceJpgBase64(0));
    $('#print').show();
    console.log(GT2ICROCX);
  } else {
    $('#IdCard')[0].reset();
    $('#IdCard').find('image').attr('src', '');
    $('#status').removeClass('succ').addClass('warn');
    $('#print').hide();
  }
}

$(function() {
  //自动读卡
  $('#btnAutoRead').on('click', '', function() {
    $(this).hide();
    $('#AutoDesc').show();
    $('#btnRead').hide();
    GT2ICROCX.Start();
  });

  //手动读卡
  $('#btnRead').on('click', '', function() {
    if (GT2ICROCX.GetState() == 0) {
      GT2ICROCX.ReadCard();
    }
  });

  //打印照片
  $('#print').on('click','',function(){
    GT2ICROCX.PrintFaceImage(0,30,10);
  });

  //禁止F5刷新
  document.onkeydown = function(e) {
      e = window.event || e;
      var keycode = e.keyCode || e.which;
      if (keycode = 116) {
        if (window.event) { // ie
          e.keyCode ? e.keyCode = 0 : e.which = 0;
          return false;
        } else { // ff
          e.preventDefault();
        }
      }
    }
  //禁止右键
  document.oncontextmenu = function(e) {
    return false;
  }  
});
